<template>
  <div id="app">
    <keep-alive :include="['datasetsprivate']">
      <router-view />
    </keep-alive>
  </div>
</template>
<style lang="less">
@import "assets/css/common.css";
@import "assets/css/global.less";

</style>
<script>
import { isStringifyJSON } from "@/utils/tool"
export default {
  data() {
    return {
      isShow: true,
      globalMsg: null
    };
  },
  methods: {
    msgFn(e) {
      if (isStringifyJSON(e.data)) {
        let msg = JSON.parse(e.data)
        console.log('2222222222',msg);
        
        // if (msg.type == 'experiment' || msg.type == "task" || msg.type == "serving") {
        if (msg.type) {
          console.log('1111111111111111',msg.type);
          
          let _t = "success"
          if (msg.levels) {
            _t = msg.levels == 1 ? 'warning' : 'error'
          }
          this.$message({
            message: msg.message,
            type: _t
          })
          this.$EventBus.$emit(msg.type, msg.data)
        }

      }
    }
  },
  mounted() {
    this.$nextTick(async () => {
      let res = await this.$myInfo(this)
      if (res && res.id) {
        this.globalMsg = new this.$ws({ url: `admin/ws/admin/${res.id}` })
        this.globalMsg.initWebSocket(this.msgFn)
      }
      // console.log(this.globalMsg.websock.send)
    })
  }
}
</script>